package top.xiaozhaobk.xiaofenshu.note.biz.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum NoteVisibleEnum {

    PUBLIC(0), // 公开，所有人可见
    PRIVATE(1); // 仅自己可见

    private final Integer code;

    /**
     * 根据类型 code 获取对应的枚举
     *
     * @param code
     * @return
     */
    public static NoteVisibleEnum valueOf(Integer code) {
        for (NoteVisibleEnum noteVisibleEnum : NoteVisibleEnum.values()) {
            if (Objects.equals(code, noteVisibleEnum.getCode())) {
                return noteVisibleEnum;
            }
        }
        return null;
    }

}
